//https://blog.csdn.net/weixin_45664402/article/details/117818808
//https://www.npmjs.com/package/cron
//https://zhuanlan.zhihu.com/p/281871686
const delay = require('delay');

let tasks = [];
const p1 = async () => {

    return Promise.resolve(1);
};
tasks.push(p1());

const p2 = async () => {

    return new Promise((resolve) => {
        resolve(2);
    });
};
tasks.push(p2());

const p3 = async () => {
    await delay(3000);
    return 3;
};
tasks.push(p3());

const p4 = async () => {
    return new Promise((resolve) => {
        setTimeout(() => {
            resolve(4);
        }, 1000);
    });
};
tasks.push(p4());

const p5 = () => {
    return Promise.resolve(5);
}
tasks.push(p5());

const p6 = new Promise((callback) => {
    callback(6);
});
tasks.push(p6);

async function start() {
    console.time('a');
    let result = await Promise.all(tasks);
    console.log(result);
    console.timeEnd('a');
}
start();